<?php
require('./includes/config.inc.php');
require(MYSQL);
if(isset($_GET['id']) && filter_var($_GET['id'], FILTER_VALIDATE_INT, array('min_ranger' => 1)))	{
	// Get the page info
	$q = 'SELECT title, description, content FROM shop_pages WHERE id='.	$_GET['id'];
	$r = mysqli_query($dbc, $q);
	
	// If no rows were returned, print an error
	if(mysqli_num_rows($r) != 1)	{
		$page_title = 'Error!';
		include('./includes/header.html');
		echo '<p class="error">This page has been accessed in error.</p>';
		include('./includes/footer.html');
		exit();
	}
	
	$row = mysqli_fetch_array($r, MYSQL_ASSOC);
	$page_title = $row['title'];
	include('includes/header.html');
	echo "<h3>page_title</h3>";
	
	// Display the content if the user's account is current
	if(isset($_SESSION['user_not_expired']))	{
		echo "<div>{row['content']}</div>";
	} elseif (isset($_SESSION['user_id']))	{ // Logged in but not current
		echo '<p class="error">Thank you for your interest in this content, but your account is no longer current. Please <a href="renew.php">renew your account</a> in order to view this page in its entirely</p>';
		echo "<div>{$row['description']}</div>";
	} else { // Not logged in
		echo '<p class="error">Thank you for your interest in this content. You must be logged in as a registered user to to view this page in its entirely.</p>';
		echo "<div>{$row['description']}</div>";
	}
} else { // No valid ID
	$page_title = 'Error!';
	include('./includes/header.html');
	echo '<p class="error">This page has been accessed in error.</p>';
}
	
include ('./includes/footer.html');
?>